<template>
    <div class="main coupon-list">
        <section>
            <div class="btn-block">
                <router-link v-if="rightsButtons['add']" :to="{name: 'activityCouponAdd'}">
                    <el-button type="success" size="small" icon="el-icon-circle-plus" plain>新建优惠券</el-button>
                </router-link>
                <router-link v-if="rightsButtons['record']" :to="{name: 'activityCouponRecord'}" style="margin-left: 24px">
                    <el-button type="primary" size="small" plain>领取记录</el-button>
                </router-link>
                <el-button v-if="rightsButtons['set']" type="warning" size="small" plain style="margin-left: 24px" @click="showConfig">全局设置</el-button>
            </div>
            <el-form ref="searchForm" class="search-block" :model="listQuery" label-position="right" label-width="96px">
                <el-row :gutter="50">
                    <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="6">
                        <el-form-item label="优惠券名称：" prop="name">
                            <el-input @keyup.enter.native="search" v-model="listQuery.name" placeholder="优惠券名称" maxlength="50" clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="6">
                        <el-form-item label="领取有效期：" prop="tempDateRange">
                            <el-date-picker
                                    v-model="listQuery.tempDateRange"
                                    type="daterange"
                                    range-separator="~"
                                    start-placeholder="开始日期"
                                    end-placeholder="结束日期"
                                    format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd hh:mm:ss">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="6">
                        <el-form-item label="状态：" prop="activityState">
                            <el-select v-model="listQuery.activityState" clearable>
                                <el-option v-for="(value, key) in activityStateData" :key="key" :label="value" :value="key"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-form-item label="" class="btn-item">
                    <el-button type="primary" size="mini" icon="el-icon-search" plain @click="search">搜索</el-button>
                    <span class="btn-reset" @click="resetForm('searchForm')">清空搜索条件</span>
                </el-form-item>
            </el-form>
            <el-table :data="list" v-loading="listLoading" header-row-class-name="table-header" element-loading-text="给我一点时间" border highlight-current-row>
                <el-table-column align="center" label="优惠券名称" prop="name" width="170"></el-table-column>
                <el-table-column align="center" label="优惠额度" prop="price" width="100">
                    <template slot-scope="scope">
                        {{scope.row.price}}元
                    </template>
                </el-table-column>
                <el-table-column align="center" label="使用门槛" prop="standardPrice" width="130">
                    <template slot-scope="scope">
                        <span v-if="scope.row.useStandard==='LIMITED'">满{{scope.row.standardPrice}}元</span>
                        <span v-else>无门槛</span>
                    </template>
                </el-table-column>
                <el-table-column align="center" label="限定范围" prop="useType" min-width="200">
                    <template slot-scope="scope">
                        <template v-if="scope.row.useType==='BY_NONE'">
                            不限制
                        </template>
                        <template v-else>
                            <div class="use-range-block" v-if="scope.row.relationList.filter(item => item.useType === 'BY_USER_GROUP').length">
                                <span>用户类型：</span><div>{{scope.row.relationList.filter(item => item.useType === 'BY_USER_GROUP').map(item => item.relationName).join('、')}}</div>
                            </div>
                            <div class="use-range-block" v-if="scope.row.relationList.filter(item => item.useType === 'BY_USER_TYPE').length">
                                <!-- <span>用户角色：</span><div>{{scope.row.relationList.filter(item => item.useType === 'BY_USER_TYPE').map(item => item.relationName).join('、')}}</div> -->
                                <span>用户角色：</span><div>{{scope.row.relationList.filter(item => item.useType === 'BY_USER_TYPE').map(item => userType[item.relationId]).join('、')}}</div>
                            </div>
                            <div class="use-range-block" v-if="scope.row.relationList.filter(item => item.useType === 'BY_MODEL_TYPE').length">
                                <span>商品模式：</span><div>{{scope.row.relationList.filter(item => item.useType === 'BY_MODEL_TYPE').map(item => item.relationName).join('、')}}</div>
                            </div>
                            <div class="use-range-block" v-if="scope.row.relationList.filter(item => item.useType === 'BY_GOODS_TYPE').length">
                                <span>商品分类：</span><div>{{scope.row.relationList.filter(item => item.useType === 'BY_GOODS_TYPE').map(item => item.relationName).join('、')}}</div>
                            </div>
                            <div class="use-range-block" v-if="scope.row.relationList.filter(item => item.useType === 'BY_GOODS').length">
                                <span>指定商品</span>
                            </div>
                            <div class="use-range-block" v-if="scope.row.relationList.filter(item => item.useType === 'BY_PACKAGE').length">
                                <span>指定套餐</span>
                            </div>
                        </template>
                    </template>
                </el-table-column>
                <el-table-column align="center" label="领取有效期" width="100">
                    <template slot-scope="scope">
                        {{formatDate(scope.row.receiveStartTime, 'YYYY/MM/DD')}}
                        {{formatDate(scope.row.receiveStopTime, 'YYYY/MM/DD')}}
                    </template>
                </el-table-column>
                <el-table-column align="center" label="使用有效期" width="100">
                    <template slot-scope="scope">
                        <template v-if="scope.row.useTimeType==='BY_DAYS'">
                            领券起{{scope.row.useDays}}天
                        </template>
                        <template v-else>
                            {{formatDate(scope.row.useStartTime, 'YYYY/MM/DD')}}
                            {{formatDate(scope.row.useStopTime, 'YYYY/MM/DD')}}
                        </template>
                    </template>
                </el-table-column>
                <el-table-column align="center" label="使用数 / 领取数 / 总数" prop="name" width="180">
                    <template slot-scope="scope">
                        {{scope.row.usedQuantity||0}} / {{scope.row.receivedQuantity||0}} / {{scope.row.quantity||'-'}}
                    </template>
                </el-table-column>
                <el-table-column align="center" label="创建时间" prop="createdAt" width="100">
                    <template slot-scope="scope">
                        {{formatDate(scope.row.createdAt, 'YYYY-MM-DD HH:mm:ss')}}
                    </template>
                </el-table-column>
                <el-table-column align="center" label="活动状态" prop="activityState" width="80">
                    <template slot-scope="scope">
                        {{activityStateData[scope.row.activeState]}}
                    </template>
                </el-table-column>
                <el-table-column align="center" label="指定用户发券" width="110">
                  <template slot-scope="scope">
                    <el-button type="text" v-if="rightsButtons['selectUser']" @click="handleSet(scope.row)">选择用户</el-button>
                    <el-button type="text" v-if="rightsButtons['batchImport']" @click="handleImport(scope.row)">批量导入</el-button>
                  </template>
                </el-table-column>
                <el-table-column align="center" label="操作" width="230" v-if="rightsButtons['view'] || rightsButtons['edit'] || rightsButtons['operate'] || rightsButtons['disable'] || rightsButtons['statistics']">
                    <template slot-scope="scope">
                        <el-button type="text" v-if="rightsButtons['view'] && (scope.row.activeState==='ACTIVITY_STATE_ONGOING'||scope.row.activeState==='ACTIVITY_STATE_INVALID')" @click="$router.push({ name: 'activityCouponView', params: { type: 'view', id: scope.row.couponActivityId } })">查看</el-button>
                        <template v-if="scope.row.activeState!=='ACTIVITY_STATE_INVALID'">
                            <el-button type="text" v-if="rightsButtons['edit'] && scope.row.activeState!=='ACTIVITY_STATE_ONGOING'" @click="$router.push({ name: 'activityCouponEdit', params: { type: 'edit', id: scope.row.couponActivityId } })">编辑</el-button>
                            <template v-if="rightsButtons['operate']">
                              <el-button type="text" v-if="scope.row.activeState==='ACTIVITY_STATE_STOPPED'" @click="operate(scope.row.couponActivityId, 'start')">开启</el-button>
                              <el-button type="text" v-else @click="operate(scope.row.couponActivityId, 'stop')">停止</el-button>
                            </template>
                            <el-button v-if="rightsButtons['disable']" type="text" @click="operate(scope.row.couponActivityId, 'disable')">作废</el-button>
                        </template>

                        <el-button v-if="rightsButtons['statistics']" type="text" @click="$router.push({ name: 'activityCouponStatistics', params: { id: scope.row.couponActivityId } })">活动统计</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page.sync="listQuery.pageIndex"
                    :page-sizes="[10, 20, 50, 100]"
                    :page-size="listQuery.pageSize"
                    background
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="listTotal">
            </el-pagination>

            <el-dialog title="优惠券全局设置" :visible.sync="dialogVisible">
                <el-form :model="formData" size="medium" ref="form" label-width="350px" label-position="left">
                    <el-form-item label="每位用户只能同时拥有的最大未使用优惠券数量:" prop="COUPON_USER_OWN_MAX_QTY" :rules="commonRules.numberRule">
                        <el-input v-model.number="formData.COUPON_USER_OWN_MAX_QTY" placeholder="请输入" maxlength="60"></el-input>
                    </el-form-item>
                    <el-form-item label="优惠券商品全局黑名单设置:">
                      <div class="use-type-block" style="margin-top: 10px;">
                        <el-button type="primary" icon="el-icon-plus" size="small" @click="chooseGoods" plain>添加商品</el-button>
                      </div>
                      <div class="use-type-block">
                        <div class="good-list" style="margin-top: 10px;">
                          <el-table :data="tempGoodsSelect" border highlight-current-row>
                            <el-table-column align="center" width="60" label="序号" type="index"></el-table-column>
                            <el-table-column align="center" width="200" label="商品款号" prop="foreignUuid"></el-table-column>
                            <el-table-column align="center" width="200" label="商品名称" prop="foreignName"></el-table-column>
                            <el-table-column align="center" label="操作" width="100">
                                <template slot-scope="scope">
                                  <el-button type="danger" size="mini" @click="removeTempSelect(scope.row)">移除</el-button>
                                </template>
                            </el-table-column>
                          </el-table>
                        </div>
                      </div>
                      <div class="use-type-block" style="margin-top: 10px;">
                        <el-button type="success" icon="el-icon-plus" size="small" @click="chooseGoodsPackage" plain>添加套餐</el-button>
                      </div>
                      <div class="use-type-block">
                        <div class="good-list" style="margin-top: 10px;">
                          <el-table :data="tempPackageSelect" border highlight-current-row>
                            <el-table-column align="center" width="60" label="序号" type="index"></el-table-column>
                            <el-table-column align="center" width="200" label="套餐款号" prop="foreignUuid"></el-table-column>
                            <el-table-column align="center" width="200" label="套餐名称" prop="foreignName"></el-table-column>
                            <el-table-column align="center" label="操作" width="100">
                                <template slot-scope="scope">
                                  <el-button type="danger" size="mini" @click="removeTempPackageSelect(scope.row)">移除</el-button>
                                </template>
                            </el-table-column>
                          </el-table>
                        </div>
                      </div>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button type="primary" @click="saveConfig" :disabled="btnDisabled">保存</el-button>
                    <el-button @click="dialogVisible = false">取消</el-button>
                </div>
            </el-dialog>
            <el-dialog title="批量导入" :visible.sync="dialogImport" @close="dialogImportClose">
                <el-form :model="importData" :rules="importDataRules" size="medium" ref="importData" label-width="100px">
                  <el-form-item label="指定会员:" prop="tempPhones" >
                    <template >
                        <div class="push-target-block">
                          <div class="textarea-box">
                              <el-input type="textarea" v-model="importData.tempPhones" :rows="3" resize="none" placeholder="请输入用户手机号，多个请用分隔符“,”隔开，自动过滤非手机号字符串" maxLength="999900"></el-input>
                          </div>
                          <div class="importBtns">
                            <el-upload
                            class="upload-demo"
                            ref="upload1"
                            :action="excelUpload"
                            name="file"
                            :on-success="uploadExcel"
                            :on-remove="handleRemove"
                            :limit='1'>
                            <el-button slot="trigger" size="small" type="primary">导入指定用户</el-button>
                          </el-upload>
                          <div>
                            <el-button type="primary" @click="saveImport('importData')">分发优惠券</el-button>
                            <el-button @click="dialogImport = false">取消</el-button>
                          </div>
                          </div>
                        </div>
                    </template>
                  </el-form-item>
                </el-form>
                <el-form :model="importUIdsData" :rules="importDataRules" size="medium" ref="importUIdsData" label-width="100px">
                  <el-form-item label="指定会员:" prop="uIds" >
                    <template >
                        <div class="push-target-block">
                          <div class="textarea-box">
                              <el-input type="textarea" v-model="importUIdsData.uIds" :rows="3" resize="none" placeholder="请输入用户ID，多个请用分隔符“,”隔开，自动过滤非用户ID字符串" maxLength="999900"></el-input>
                          </div>
                          <div class="importBtns">
                            <el-upload
                            class="upload-demo"
                            ref="upload2"
                            :action="excelUpload"
                            name="file"
                            :on-success="uploadUIdsExcel"
                            :on-remove="handleUIdsRemove"
                            :limit='1'>
                            <el-button slot="trigger" size="small" type="primary">导入指定用户</el-button>
                          </el-upload>
                          <div>
                            <el-button type="primary" @click="saveImport('importUIdsData')">分发优惠券</el-button>
                            <el-button @click="dialogImport = false">取消</el-button>
                          </div>
                          </div>
                        </div>
                    </template>
                  </el-form-item>
                </el-form>
            </el-dialog>
        </section>
    </div>
</template>
<script>
    export default {
      name: 'activityCoupon',
      data(){
        return {
          fileList: [], // 批量导入模板列表
          tempUsersSelect:[], // 设置用户
          tempGoodsSelect: [], // 全局设置黑名单商品
          tempPackageSelect: [], // 全局设置黑名单套餐
          importData: { // 批量导入表单数据
            tempPhones: ''
          },
          importUIdsData: { // 批量导入用户Id表单数据
             uIds:''
          },
          dialogImport: false, // 批量导入弹框model
          importDataRules: {
            tempPhones: [
              { required: true, message: '指定会员不能为空', trigger: 'blur' },
              { required: true, message: '指定会员不能为空', trigger: 'change' }
            ],
            uIds: [
              { required: true, message: '指定会员不能为空', trigger: 'blur' },
              { required: true, message: '指定会员不能为空', trigger: 'change' }
            ]
          }, // 批量导入表单校验
          couponActivityId: '', // 批量导入分发优惠券id
          activityStateData: {
            'ACTIVITY_STATE_NOT_STARTED': '未开始',
            'ACTIVITY_STATE_ONGOING': '进行中',
            'ACTIVITY_STATE_STOPPED': '已停止',
            'ACTIVITY_STATE_INVALID': '已失效'
          },
          useTypeData: {
            'BY_USER_TYPE': '指定用户角色：',
            'BY_GOODS_TYPE': '指定商品分类：'
          },
          operateTypeData: {
            'start': '开启',
            'stop': '停止',
            'disable': '作废'
          },

          listLoading: false,
          listQuery: {
            tempDateRange: [],

            name: '',
            receiveStartTime: '',
            receiveStopTime: '',
            activityState: '',
            pageIndex: 1,
            pageSize: 10
          },
          list: [],
          listTotal: 0,

          dialogVisible: false,
          btnDisabled: false,
          formData: {
            COUPON_USER_OWN_MAX_QTY: ''
          },
          userType:{}
        }
      },
      activated(){
        this.getList();
      },
      created () {
        this.userType = this.$enum.vipGrade
        if (this.$store.getters.cachedViews.length === 0) this.getList();
      },
      methods: {
        // 批量导入弹框关闭操作
        dialogImportClose () {
          this.$refs['importData'].clearValidate()
        },
        // 全局设置 添加商品
        chooseGoods () {
          let selected = this.tempGoodsSelect.map(item => {
            return {
              goodsId: item.foreignUuid,
              name: item.foreignName,
              id: item.foreignKey,
              serialNo: !item.serialNo ? '' : item.serialNo
            }
          });
          this.goodsChoose({}, selected).then(val => {
            this.tempGoodsSelect = this.tempGoodsSelect.filter(item=>item.type===2).concat(val.map(item => {
              return {
                foreignUuid: item.goodsId,
                foreignKey: item.id,
                foreignName: item.name,
                serialNo: !item.serialNo ? '' : item.serialNo,
                type: 1,
                from_type: 1
              }
            }))
          });
        },
        // 全局设置 添加套餐
        chooseGoodsPackage () {
          let selected = this.tempPackageSelect.map(item => {
            return {
              packageId: item.foreignUuid,
              name: item.foreignName,
              id: item.foreignKey,
              serialNo: !item.serialNo ? '' : item.serialNo
            }
          });
          this.packageChoose({}, selected).then(val => {
            this.tempPackageSelect = this.tempPackageSelect.filter(item=>item.type===1).concat(val.map(item => {
              return {
                foreignUuid: item.packageId,
                foreignKey: item.id,
                foreignName: item.name,
                serialNo: !item.serialNo ? '' : item.serialNo,
                type: 2,
                from_type: 3
              }
            }))
          });
        },
        // 全局设置 商品移除
        removeTempSelect (item) {
          const _this = this
          this.$confirm(`确定要删除 ${item.foreignName} 吗?`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            _this.tempGoodsSelect.splice(_this.tempGoodsSelect.indexOf(item), 1)
          }).catch(err => {
            console.log(err);
          });
        },
        // 全局设置 套餐移除
        removeTempPackageSelect (item) {
          const _this = this
          this.$confirm(`确定要删除 ${item.foreignName} 吗?`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            _this.tempPackageSelect.splice(_this.tempPackageSelect.indexOf(item), 1)
          }).catch(err => {
            console.log(err);
          });
        },
        // 批量导入保存
        saveImport (name) {
          name=='importData' && this.$refs[name].validate((valid) => {
            if (valid) {
              this.request({
                url: '/coupon/system/distributeByPhone',
                method: 'post',
                data: {
                  couponActivityId: this.couponActivityId,
                  phones: this.importData.tempPhones.split(','),
                  type:1
                }
              }).then((res) => {
                if (res.code === 200 || res.status === 200) {
                  this.$message.success('分发提交成功，优惠券以实际到账为准')
                  this.dialogImport = false
                }
              }).catch(err => {
                console.log(err)
                this.dialogImport = true
              })
            }
          })
          name=='importUIdsData' && this.$refs[name].validate((valid) => {
            if (valid) {
              this.request({
                url: '/coupon/system/distributeByPhone',
                method: 'post',
                data: {
                  couponActivityId: this.couponActivityId,
                  phones:this.importUIdsData.uIds.split(','),
                  type:2
                }
              }).then((res) => {
                if (res.code === 200 || res.status === 200) {
                  this.$message.success('分发提交成功，优惠券以实际到账为准')
                  this.dialogImport = false
                }
              }).catch(err => {
                console.log(err)
                this.dialogImport = true
              })
            }
          })
        },
        // 删除后批量导入文件
        handleRemove () {
          this.importData.tempPhones = ''
        },
        handleUIdsRemove () {
          this.importUIdsData.uIds = ''
        },
        // 批量导入成功
        uploadExcel(res) {
          this.importData.tempPhones = res.data
        },
        uploadUIdsExcel(res){
          this.importUIdsData.uIds =  res.data
        },
        // 处理批量导入
        handleImport (row) {
          // 只有在优惠券状态为“未开始”及“进行中”状态下才可进行参数配置
          if (row.activeState !== 'ACTIVITY_STATE_ONGOING' && row.activeState !== 'ACTIVITY_STATE_NOT_STARTED') {
            this.$message.warning('优惠券状态不符，无法分发优惠券')
            return false;
          }
          this.importData.tempPhones = ''
          this.importUIdsData.uIds = ''
          this.couponActivityId = row.couponActivityId
          this.dialogImport = true
          this.$nextTick(()=>{
            this.$refs.importData.clearValidate()
            this.$refs.importUIdsData.clearValidate()
          })
        },
        // 设置
        handleSet (row) {
          // 只有在优惠券状态为“未开始”及“进行中”状态下才可进行参数配置
          if (row.activeState !== 'ACTIVITY_STATE_ONGOING' && row.activeState !== 'ACTIVITY_STATE_NOT_STARTED') {
            this.$message.warning('优惠券状态不符，无法分发优惠券')
            return false;
          }
          this.usersChoose().then(val => {
            let selected = val.map(item => {
              return item.mobile
            });
            this.request({
              url: '/coupon/system/distributeByPhone',
              method: 'post',
              data: {
                couponActivityId: row.couponActivityId,
                phones: selected
              }
            }).then((res) => {
              if (res.code === 200 || res.status === 200) {
                this.$message.success('导入成功')
              }
            }).catch(err => {
              console.log(err)
            })
            this.tempUsersSelect = this.tempUsersSelect.concat(val.map(item => {
              return {
                id: item.id,
                mobile: item.mobile,
                nickname: item.nickname
              }
            }))
          });
        },
        // 获取列表
        getList () {
          this.listLoading = true;
          let date = this.listQuery.tempDateRange;
          this.listQuery.receiveStartTime = date && date.length ? date[0] : '';
          this.listQuery.receiveStopTime = date && date.length ? date[1] : '';

          this.request({
            url: '/coupon/system/activity/query',
            method: 'post',
            data: this.listQuery
          }).then(({data, totalCount}) => {
            this.list = data;
            this.listTotal = totalCount;
            this.listLoading = false;
          }).catch(err => {
            console.log(err);
            this.list = [];
            this.listTotal = 0;
            this.listLoading = false;
          });
        },
        // 清空搜索条件
        resetForm (formName) {
          this.$nextTick(() => {
            this.$refs[formName].resetFields()
          })
        },
        // 搜索
        search() {
          this.listQuery.pageIndex = 1;
          this.getList();
        },
        //切换每页条数
        handleSizeChange (value) {
          this.listQuery.pageSize = value;
          this.getList()
        },
        // 切换分页
        handleCurrentChange(page) {
          this.listQuery.pageIndex = page;
          this.getList();
        },

        // 操作优惠券
        operate(couponActivityId, type) {
          let warnMsg = type === 'disable' ? '作废后将会使已领取的券变为失效，可能遭到用户投诉，确认还要作废吗？' : `${this.operateTypeData[type]}该优惠券, 是否继续?`;
          this.$confirm(warnMsg, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.request({
              url: `/coupon/system/activity/${type}`,
              method: 'post',
              data: { couponActivityId },
              headers: {
                authorKey: `${this.$route.name}Disable`
              }
            }).then(({data}) => {
              this.$message.success(`优惠券活动已成功${this.operateTypeData[type]}`)
              this.getList()
            }).catch(err => {
              console.log(err);
            });
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消操作'
            });
          });
        },

        // 显示全局设置
        showConfig(){
          this.request({
            url: '/coupon/system/settings/getGlobal',
            method: 'post',
            data: {
              key: 'COUPON_USER_OWN_MAX_QTY'
            }
          }).then(({data}) => {
            this.formData.COUPON_USER_OWN_MAX_QTY = data.value
            this.tempGoodsSelect = data.goodsBlackList
            this.tempPackageSelect = data.packageBlackList
            this.dialogVisible = true
          }).catch(err => {
            console.log(err);
            this.formData.COUPON_USER_OWN_MAX_QTY = ''
          });
        },
        // 保存全局设置
        saveConfig(){
          this.$refs.form.validate(validBase => {
            if (!validBase) {
              return false;
            }

            this.request({
              url: '/coupon/system/settings/set',
              method: 'post',
              data: {
                key: 'COUPON_USER_OWN_MAX_QTY',
                value: this.formData.COUPON_USER_OWN_MAX_QTY,
                goodsCouponBlackList: this.tempGoodsSelect,
                packageBlackList: this.tempPackageSelect
              },
              headers: {
                authorKey: `${this.$route.name}Set`
              }
            }).then((res) => {
              if (res.code === 200 || res.status === 200) {
                this.$message.success('保存成功');
                this.dialogVisible = false;
              }
            }).catch(err => {
              console.log(err);
            });
          });
        }
      }
    }
</script>
<style lang="scss">
    @import "../../../styles/mixin";
    .push-target-block{
      @include flex;
      margin-left: 24px;
      .textarea-box {
        margin-right: 10px;
        width: 330px;
      }
      .importBtns{
        display: flex;
        flex-direction: column;
        justify-content: space-between;
      }
    }
    .coupon-list {
      .use-range-block{
        @include flex;
        text-align: left;
        div{
            @include sub-item;
        }
      }
      .use-type-block{
        @include flex;
        margin-left: -150px;
      }
    }
</style>
